import { getHotList, getGoodsList } from '../../api/home'

const state = {
  hotList: [],
  goodsList: []
}
const mutations = {
  GETHOTLIST(state, hotList) {
    state.hotList = hotList
  },
  GETGOODSLIST(state, goodsList) {
    state.goodsList = goodsList
  }
}
const actions = {
  async getHotList({ commit }) {
    const { data } = await getHotList()
    if (data.code == 200) {
      commit('GETHOTLIST', data.data)
    }
  },
  async getGoodsList({ commit }, query) {
    const { data } = await getGoodsList(query)
    if (data.code == 200) {
      commit('GETGOODSLIST', data.data)
    } else {
      commit('GETGOODSLIST', [])
    }
  }
}
const getters = {}

export default {
  state,
  mutations,
  actions,
  getters
}
